package com.anbinh.doctor.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.anbinh.doctor.R;
import com.anbinh.doctor.model.DistrictResponse.Data.Item;

public class DistrictAdapter extends ArrayAdapter<Item> {
	private int resource;
	private LayoutInflater layoutInflater;
	private List<Item> listData;
	private int idCheked;

	public DistrictAdapter(Context mContext, int resource, List<Item> models, int idChecked) {
		super(mContext, resource, models);
		this.resource = resource;
		this.listData = models;
		layoutInflater = LayoutInflater.from(mContext);
		this.idCheked = idChecked;
	}

	public class ViewHolder {
		public TextView lblHisAmount;
	}

	@Override
	public Item getItem(int position) {
	    return listData.get(position);
	}
	
	@Override
	public long getItemId(int position) {
	    return listData.get(position).getId();
	}
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(resource, null, true);

			viewHolder.lblHisAmount = (TextView) convertView
					.findViewById(R.id.btnCheck);
	
			convertView.setTag(viewHolder);

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		Item item = getItem(position);
	
		viewHolder.lblHisAmount.setText(item.getName());
		

		return convertView;
	}
}
